package com.hodgepodge.commons.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.hodgepodge.commons.base.entity.SuperEntity;
import com.hodgepodge.commons.validator.group.Insert;
import com.hodgepodge.commons.validator.group.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * <p>
 * 标签表
 * </p>
 *
 * @author jiangjian
 * @since 2021-02-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "标签")
public class Tag extends SuperEntity<Tag> {

    private static final long serialVersionUID = 1L;

    /**
     * 标签ID
     */
    @ApiModelProperty(value = "标签ID")
    @NotNull(message = "标签ID不能为空", groups = Update.class)
    @TableId("tag_id")
    private Long tagId;

    /**
     * 标签名称
     */
    @ApiModelProperty(value = "标签名称")
    @NotBlank(message = "标签名称不能为空", groups = Insert.class)
    @Length(max = 20, message = "标签名称不能超过20个字符", groups = {Insert.class, Update.class})
    private String name;

    /**
     * 标签别名
     */
    @ApiModelProperty(value = "标签别名")
    @Length(max = 15, message = "标签别名不能超过15个字符", groups = {Insert.class, Update.class})
    private String alias;

    /**
     * 权重
     */
    @ApiModelProperty(value = "权重")
    private Integer weight;

    /**
     * 标签描述
     */
    @ApiModelProperty(value = "标签描述")
    @Length(max = 255, message = "标签描述不能超过255个字符", groups = {Insert.class, Update.class})
    private String summary;


    @Override
    protected Serializable pkVal() {
        return this.tagId;
    }

}
